<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>新增教师</title>
    <link rel="stylesheet" href="static/layui/css/layui.css">
<!--    <link rel="stylesheet" href="static/css/style.css">-->
    <style>
        body{background-color: white}
        .layui-form-label{
            width: 100px;
        }
        .layui-input-block {
            margin-left: 130px;
            min-height: 36px
        }
    </style>
    <script src="static/login/js/jquery.min.js"></script>
</head>
<body class="body">
<!--templates/insert/jsxxgl-->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>新增教师</legend>
</fieldset>

<form class="layui-form layui-from-pane" style="margin-top:20px" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">教师姓名：</label>
        <div class="layui-input-block">
            <input type="text" name="tname"  required  lay-verify="required" autocomplete="off" placeholder="请输入教师姓名" class="layui-input" style="width: 90%">
        </div>
    </div>

    <div class="w3_agileits_main_grid w3l_main_grid">
            <span class="agileits_grid">
                <label  style="margin-left: 75px;margin-right: 20px">性别<i>:</i></label>
                <div class="layui-input-inline">
                   <select name="xb" id="xb">
                       <option value="男">男</option>
                       <option value="女">女</option>
                   </select>
                </div>
            </span>
    </div>
    <br>
    <div class="layui-form-item">
        <label class="layui-form-label">生日：</label>
        <div class="layui-input-block">
            <input type="date" name="birth"  required  lay-verify="required" autocomplete="off" placeholder="请选择生日" class="layui-input" style="width: 90%">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">职称：</label>
        <div class="layui-input-block">
            <input type="text" name="zyzc" required  lay-verify="required" autocomplete="off" placeholder="请输入职称" class="layui-input" style="width: 90%">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">电话：</label>
        <div class="layui-input-block">
            <input type="text" name="tel" required  lay-verify="required" autocomplete="off" placeholder="请输入电话" class="layui-input" style="width: 90%">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">工号：</label>
        <div class="layui-input-block">
            <input type="text" name="idcard" required  lay-verify="required" autocomplete="off" placeholder="请输入工号" class="layui-input" style="width: 90%">
        </div>
        <br>
        <span id="tipinfo" style="color: red;margin-left: 60px;"></span>
    </div>

    <div class="layui-form-item" style="margin-top:40px">
        <div class="layui-input-block">
            <button class="layui-btn  layui-btn-submit " lay-submit="" lay-filter="demo1">添加</button>
        </div>
    </div>
</form>
<script>
    $.ajax({
        url:"/selectjslast",
        type:"post",
        dataType:"json",
        success: function (result) {
            var string = "推荐工号："+result.data[0].idcard;
            $("#tipinfo").html(string);
        }
    });
</script>
<script src="static/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form','layer','jquery'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,$=layui.jquery
        //监听提交
        form.on('submit(demo1)', function(data){
            var xb = $('#xb').val();
            $.ajax({

                url:'/Insertjsxxgl',
                type:'POST',
                dataType:'json',
                data:{tname:data.field.tname,
                    birth:data.field.birth,
                    zyzc:data.field.zyzc,
                    tel:data.field.tel,
                    idcard:data.field.idcard,
                    xb:xb
                },
                success:function (msg) {
                    if(msg){
                        layer.closeAll('loading');
                        layer.load(2);
                        layer.msg("添加成功", {icon: 1});
                        setTimeout(function(){
                            window.parent.location.reload();//修改成功后刷新父界面
                        }, 1000);
                        //加载层-风格

                    }else{
                        layer.msg("已存在该工号教师您可以根据推荐工号填写", {icon: 2});
                    }
                }
            })
            return false;
        });
    });
</script>
</body>
</html>